﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Model;
using Dal;
using System.Data;

namespace Bll
{
    public class BllPublic
    {
        DalPublic d = new DalPublic();

        //信息
        public DataTable Nav_Inquire_All()
        {
            //一级导航全部信息
            return d.Nav_Inquire_All();
        }//一级导航全部信息

        public int Information_Count_Img_Number(ModelPublic m)
        {
            //统计推荐图片当天个数
            return d.Information_Count_Img_Number(m);
        }//统计推荐图片当天个数

        public int Information_Count_File_Number(ModelPublic m)
        {
            //统计资料文件当天个数
            return d.Information_Count_File_Number(m);
        }//统计资料文件当天个数
        
        public string Information_Id(ModelPublic m)
        {
            //信息编号
            return d.Information_Id(m);
        }//信息编号
        
        public string Information_Add(ModelPublic m)
        {
            //添加信息
            if (m.NavSubId == "0")
            {
                return "请选择二级目录！";
            }
            if (m.Title == "")
            {
                return "请输入新闻标题！";
            }
            if (m.Recommend=="True" && m.RecommendName=="NULL")
            {
                return "请选择展示图片！";
            }
            if (m.DateTime == "NULL")
            {
                return "请输入发布时间！";
            }
            else if (m.Author == "NULL")
            {
                return "请输入新闻作者！";
            }
            if (m.FileName=="NULL" && m.NavId=="9")
            {
                return "请选择资料文件！";
            }
            if (!d.Information_IsTitle(m))//判断标题是否存在
            {
                if(d.Information_Add(m))
                    return "1";
                else
                    return "添加失败！";
            }
            else
                return "标题已存在！";
        }//添加信息

        public DataTable SubNav_Inquire_All(ModelPublic m)
        {
            //二级导航全部信息
            return d.SubNav_Inquire_All(m);
        }//二级导航全部信息

        public DataTable Information_Inquire_All(ModelPublic m)
        {
            //获取全部信息(发布版)
            return d.Information_Inquire_All(m);
        }//获取全部信息(发布版)

        public DataTable Information_Inquire_All_Unpublished(ModelPublic m)
        {
            //获取全部信息(未发布版)
            return d.Information_Inquire_All_Unpublished(m);
        }//获取全部信息(未发布版)

        public DataTable Information_Inquire_Single(ModelPublic m)
        {
            //查询单条信息
            return d.Information_Inquire_Single(m);
        }//查询单条信息

        public DataTable Information_Search_All(ModelPublic m)
        {
            //检索信息(发布版)
            return d.Information_Search_All(m);
        }//检索信息(发布版)

        public DataTable Information_Search_All_Unpublished(ModelPublic m)
        {
            //检索信息(未发布版)
            return d.Information_Search_All_Unpublished(m);
        }//检索信息(未发布版)
        
        public bool Information_Delete(ModelPublic m)
        {
            //信息删除
            return d.Information_Delete(m);
        }//信息删除

        public string Information_Modify(ModelPublic m)
        {
            //信息修改
            if (d.Information_Modify(m))
                return "1";
            else
                return "修改失败！";
        }//信息修改


        //通知公告+周行事历
        
        public int Notice_Week_Count_File_Number(ModelPublic m)
        {
            //统计资料文件当天个数
            return d.Notice_Week_Count_File_Number(m);
        }//统计资料文件当天个数

        public string Notice_Week_Id(ModelPublic m)
        {
            //通知公告编号
            return d.Notice_Week_Id(m);
        }//通知公告编号

        public string Notice_Week_Add(ModelPublic m)
        {
            //通知、周行事添加
            if (m.Title=="")
            {
                return "请输入新闻标题！";
            }
            if(m.Weekly=="" && m.Type=="0")
            {
                return "请输入周次！";
            }
            if(m.Author=="")
            {
                return "请输入新闻作者！";
            }
            if(m.DateTime=="")
            {
                return "请输入新闻时间！";
            }
            if(m.FileName== "NULL")
            {
                return "请选择资料文件！";
            }
            
            if (!d.Notice_Week_IsTitle(m))
            {
                if (d.Notice_Week_Add(m))
                    return "1";
                else
                    return "添加失败！";
            }
            else
                return "标题已存在！";
            
        }//通知、周行事添加
        
        public DataTable Notice_Week_Inquire_All(ModelPublic m)
        {
            //获取全部信息(发布版)
            return d.Notice_Week_Inquire_All(m);
        }//获取全部信息(发布版)

        public DataTable Notice_Week_Inquire_All_Unpublished(ModelPublic m)
        {
            //获取全部信息(未发布版)
            return d.Notice_Week_Inquire_All_Unpublished(m);
        }//获取全部信息(未发布版)

        public DataTable Notice_Week_Search_All(ModelPublic m)
        {
            //检索信息(发布版)
            return d.Notice_Week_Search_All(m);
        }//检索信息(发布版)

        public DataTable Notice_Week_Search_All_Unpublished(ModelPublic m)
        {
            //检索信息(未发布版)
            return d.Notice_Week_Search_All_Unpublished(m);
        }//检索信息(未发布版)

        public DataTable Notice_Week_Inquire_Single(ModelPublic m)
        {
            //查询单条信息
            return d.Notice_Week_Inquire_Single(m);
        }//查询单条信息

        public bool Notice_Week_Delete(ModelPublic m)
        {
            //信息删除
            return d.Notice_Week_Delete(m);
        }//信息删除

        public string Notice_Week_Modify(ModelPublic m)
        {
            //信息修改
            if (d.Notice_Week_Modify(m))
                return "1";
            else
                return "修改失败！";
        }//信息修改
    }
}
